package com.example.mh14;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * Created by swallow on 2020/12/28.
 */
@Controller
public class ArticleController {
    @Autowired
    private ArticleDao articleDao;

    @GetMapping("list")
    public String list(Model model, @RequestParam(name = "pageNum", defaultValue = "1", required = false) int pageNum, @RequestParam(name = "pageSize", defaultValue = "3", required = false) int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        PageInfo<Article> page = new PageInfo<>(articleDao.findList());
        model.addAttribute("page", page);
        return "client/index";
    }
}
